<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.listForm.zhuCeXinXi"/><spring:message code="message.jqGrid.cz.audit"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
    <link href="${ctx}/lib/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" />
    <style type="text/css">
    	span.required {
    		color: red;
    		margin-right: 6px;
    	}
    	.text-left{
    	    color:#949494;
    	}
    	.box-body {
         margin-bottom: -20px;
        }
    </style>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.listForm.zhuCeXinXi"/><spring:message code="message.jqGrid.cz.audit"/></h1>
         <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.listForm.zhuCeShenHe"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.listForm.zhuCeXinXi"/><spring:message code="message.listForm.lieBiao"/></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success ">
            <form id="form" class="form-horizontal" action="saveAuditHeaBur.html" method="post">
            	<input type="hidden" name="heaBurId" value="${regHealthbureau.heaBurId}" />  
            	<div class="box-header with-border">
                   <h3 class="box-title"><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.listForm.xinXi"/></h3>
                </div>          	
                <div class="box-body">                 
                    <div class="form-group form-group-xs">
                        <label for="hospCode" class="col-sm-2 text-right"><spring:message code="message.lable.weiShengJuBianMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="heaBurCode" name="heaBurCode" value="<c:out value="${ regHealthbureau.heaBurCode }"></c:out>" placeholder="<spring:message code="message.lable.weiShengJuBianMa"/>" type="hidden" maxlength="50"><c:out value="${ regHealthbureau.heaBurCode }"></c:out>
                        </div>
                        <label for="hospName" class="col-sm-3 text-right"><spring:message code="message.lable.weiShengJuMingCheng"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="heaBurName" name="heaBurName" value="<c:out value="${ regHealthbureau.heaBurName }"></c:out>" placeholder="<spring:message code="message.lable.weiShengJuMingCheng"/>" type="hidden" maxlength="100"><c:out value="${ regHealthbureau.heaBurName }"></c:out>
                        </div>
                    </div>
                    <div class="line"></div>
                    <div class="form-group form-group-xs">
                        <label for="orgCode" class="col-sm-2 text-right"><spring:message code="message.listForm.zuZhiJiGouDaiMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="orgCode" name="orgCode" value="<c:out value="${ regHealthbureau.orgCode }"></c:out>" placeholder="<spring:message code="message.listForm.zuZhiJiGouDaiMa"/>" type="hidden" maxlength="20"><c:out value="${ regHealthbureau.orgCode }"></c:out>
                        </div>
                        <label for="hospPhone" class="col-sm-3 text-right"><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.lable.phone"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="hospPhone" name="hospPhone" value="<c:out value="${ regHealthbureau.hospPhone }"></c:out>" placeholder="<spring:message code="message.listForm.weiShengJu"/><spring:message code="message.lable.phone"/>" type="hidden" maxlength="20"><c:out value="${ regHealthbureau.hospPhone }"></c:out>
                        </div>
                    </div>
                    <div class="line"></div>
                    <div class="form-group form-group-xs">
                   	 <label for="area" class="col-sm-2 text-right"><spring:message code="message.listForm.zhuCe"/><spring:message code="message.listForm.diQu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input id="area3" name="area.areaid" type="hidden" class="form-control" value="<c:out value="${regHealthbureau.area.areaid  }"></c:out>"  style="width:31%;display:inline-block;"><c:out value="${regHealthbureau.area.arfullname  }"></c:out>
                        </div>
                        <label for="staffNum" class="col-sm-3 text-right"><spring:message code="message.listForm.yuanGongShu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="staffNum" name="staffNum" value="<c:out value="${ regHealthbureau.staffNum }"></c:out>" placeholder="<spring:message code="message.listForm.yuanGongShu"/>" type="hidden" maxlength="11"><c:out value="${ regHealthbureau.staffNum }"></c:out>
                        </div>
                    </div>
                        <div class="line"></div>
                          <div class="form-group form-group-xs">
                        <label for="hospAddress" class="col-sm-2 text-right"><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.listForm.diZhi"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-9 text-left">
                            <input type="hidden" class="form-control" id="hospAddress" name="hospAddress"  placeholder="<spring:message code="message.listForm.weiShengJu"/><spring:message code="message.listForm.diZhi"/>" maxlength="512" value="<c:out value="${regHealthbureau.hospAddress  }"></c:out>"><c:out value="${regHealthbureau.hospAddress  }"></c:out>
                        </div>
                    </div>
                    <div class="line"></div>
                    <div class="form-group form-group-xs">
                        <label for="profile" class="col-sm-2 text-right"><spring:message code="message.listForm.weiShengJu"/><spring:message code="message.listForm.jianJie"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-9 text-left">
                            <input class="form-control" id="profile" name="profile" value="<c:out value="${regHealthbureau.profile  }"></c:out>" placeholder="<spring:message code="message.listForm.jianJie"/>" maxlength="1000" type="hidden"><c:out value="${regHealthbureau.profile  }"></c:out>
                        </div>
                    </div>
                   </div>
                <div class="box-header with-border">
                <h3 class="box-title"><spring:message code="message.listForm.liangXiRenxinxi"/></h3>
                </div>
                <div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="contactName" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenXingMing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactName" name="contactName" value="<c:out value="${ regHealthbureau.contactName }"></c:out>" placeholder="<spring:message code="message.listForm.liangXiRenXingMing"/>" type="hidden" maxlength="10"><c:out value="${ regHealthbureau.contactName }"></c:out>
                        </div>
                        <label for="contactIdnum" class="col-sm-3 text-right"><spring:message code="message.listForm.liangXiRenShengFenZheng"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactIdnum" name="contactIdnum" value="<c:out value="${ regHealthbureau.contactIdnum }"></c:out>" placeholder="<spring:message code="message.listForm.liangXiRenShengFenZheng"/>" type="hidden" maxlength="20"><c:out value="${ regHealthbureau.contactIdnum }"></c:out>
                        </div>
                    </div>
                    <div class="line"></div>
                    <div class="form-group form-group-xs">
                        <label for="contactPos" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenZhiWu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactPos" name="contactPos" value="<c:out value="${ regHealthbureau.contactPos }"></c:out>" placeholder="<spring:message code="message.listForm.liangXiRenZhiWu"/>" type="hidden" maxlength="32"><c:out value="${ regHealthbureau.contactPos }"></c:out>
                        </div>
                        <label for="contactTelephone" class="col-sm-3 text-right"><spring:message code="message.listForm.liangXiRenDianHua"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactTelephone" name="contactTelephone" value="<c:out value="${ regHealthbureau.contactTelephone }"></c:out>" placeholder="<spring:message code="message.listForm.liangXiRenDianHua"/>" type="hidden" maxlength="20"><c:out value="${ regHealthbureau.contactTelephone }"></c:out>
                        </div>
                    </div>
                    <div class="line"></div>
                    <div class="form-group form-group-xs">
                        <label for="contactHandphone" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenShouJi"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactHandphone" name="contactHandphone" value="<c:out value="${ regHealthbureau.contactHandphone }"></c:out>" placeholder="<spring:message code="message.listForm.liangXiRenShouJi"/>" type="hidden" maxlength="20"><c:out value="${ regHealthbureau.contactHandphone }"></c:out>
                        </div>
                        <label for="contactEmail" class="col-sm-3 text-right"><spring:message code="message.listForm.liangXiRenYouXiang"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactEmail" name="contactEmail" value="<c:out value="${ regHealthbureau.contactEmail }"></c:out>" placeholder="<spring:message code="message.listForm.liangXiRenYouXiang"/>" type="hidden" maxlength="20"><c:out value="${ regHealthbureau.contactEmail }"></c:out>
                        </div>
                    </div>
                    <div class="line"></div>
                    <div class="form-group form-group-xs">
                        <label for="contactQq" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenQQ"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactQq" name="contactQq" value="<c:out value="${ regHealthbureau.contactQq }"></c:out>" placeholder="<spring:message code="message.listForm.liangXiRenQQ"/>" type="hidden" maxlength="20"><c:out value="${ regHealthbureau.contactQq }"></c:out>
                        </div>
                    </div>
                    
                    <div class="line"></div>
                    <div class="form-group form-group-xs">
                    <input type="hidden" class="form-control" id="auditStatus" name="auditStatus">
                        <label for="auditRemark" class="col-sm-2 control-label"><spring:message code="message.listForm.shenHeBeiZhu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-9">
                            <textarea class="form-control" id="auditRemark" name="auditRemark" rows="3" placeholder="<spring:message code="message.listForm.shenHeBeiZhu"/>" maxlength="500"></textarea>
                        </div>
                    </div>
                 </div>   
                <div class="box-footer text-center">
                    <button type="button" class="btn btn-primary btn-sm" onclick="saveAuditUser(1);"><spring:message code="message.listForm.tongGuoSpacing"/></button>
                    <button type="button" class="btn btn-primary btn-sm" onclick="saveAuditUser(2);"><spring:message code="message.listForm.buTongGuo"/></button>
                    <a href="${ctx }/auditUser/toAuditHeaBurList.html" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
                </div>
            </form>
        </div>
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script src="${ctx}/lib/plugins/daterangepicker/moment.js"></script>
    <script src="${ctx}/lib/plugins/daterangepicker/daterangepicker.js"></script>
    
    <script type="text/javascript">
    
    	//	保存角色信息
    	function saveAuditUser(status) {
    		$("#auditStatus").val(status);
    		if (!validate()) {
    			return;
    		}
    		//	通过查询基础库是否存在
    		if ($("#auditStatus").val() == "1") {
    			$.post("checkHeaBurExist.html", {
        			"heaBurName" : $.trim($("#heaBurName").val())
        		}, function(result) {
        			if (result.success && result.rows) {
        				$.HN.message.confirm("<spring:message code="message.listForm.weiShengJuKu"/><spring:message code="message.listForm.zhong"/><spring:message code="message.listForm.alreadyShow"/><spring:message code="message.listForm.alreadyShow"/>", "", "").on(function(bool) {
        					if (bool) {
        						submitSave();
        					}
        				});
        			} else {
        				submitSave();
        			}
        		}, "json").error(function(err) {
        			top.window.document.location = "${ctx}/login.html"; 
        		});
    		} else {	//	不通过
    			submitSave();
    		}
    	}
    	
    	//	提交保存
    	function submitSave() {
   			$("#form").ajaxSubmit({
       			dataType : "json",
       			timeout: 10000,
       			success : function(result, statusText) {
       				if (result.success) {
       					
       						top.$.HN.message.alert("<spring:message code="message.HN.alert.baoCunCheng"/>", "", "success", function() {
           					});
       						setTimeout("document.location = '${ctx }/auditUser/toAuditHeaBurList.html'", 500) 
       				} else {
       					$.HN.message.alert(result.msg || "", "", "error");
       				}
       			}
       		});
    	}
    	
    	//	校验角色信息
    	 function validate() {
    		var heaBurCode = $.trim($("#heaBurCode").val());
    		if (heaBurCode == null || heaBurCode == "") {
    			$.HN.message.alert("请输入卫生局编码！", "消息", "warn");
    			return false;
    		} else if (!/^[a-zA-Z0-9_]+$/.test(heaBurCode)) {
    			$.HN.message.alert("卫生局编码只能由字母数字下划线组成！", "消息", "warn");
    			return false;
    		}else if (heaBurCode.length > 100 ) {
                $.HN.message.alert("卫生局编码超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#heaBurCode").val(heaBurCode);

    		var heaBurName = $.trim($("#heaBurName").val());
    		if (heaBurName == null || heaBurName == "") {
    			$.HN.message.alert("请输入卫生局名称！", "消息", "warn");
    			return false;
    		}else if (heaBurName.length > 512 ) {
                $.HN.message.alert("卫生局名称超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#heaBurName").val(heaBurName);


    		var orgCode = $.trim($("#orgCode").val());
    		if (orgCode == null || orgCode == "") {
    			$.HN.message.alert("请输入组织机构代码！", "消息", "warn");
    			return false;
    		} else if (!/^[a-zA-Z0-9_]+$/.test(orgCode)) {
    			$.HN.message.alert("组织机构代码只能由字母数字下划线组成！", "消息", "warn");
    			return;
    		}else if (orgCode.length > 20 ) {
                $.HN.message.alert("卫生局代码超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#orgCode").val(orgCode);


    		var hospPhone = $.trim($("#hospPhone").val());
    		if (hospPhone == null || hospPhone == "") {
    			$.HN.message.alert("请输入卫生局电话！", "消息", "warn");
    			return false;
    		} else if (!/^(\d+[-]\d+)|(\d+)$/.test(hospPhone)) {
    			$.HN.message.alert("请输入正确的卫生局电话！", "消息", "warn");
    			return false;
    		}else if (hospPhone.length > 20 ) {
                $.HN.message.alert("卫生局电话超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#hospPhone").val(hospPhone);
    		
    		var hospAddress = $.trim($("#hospAddress").val());
    		if (hospAddress == null || hospAddress == "") {
    			$.HN.message.alert("请输入卫生局地址！", "消息", "warn");
    			return false;
    		}else if (hospAddress.length > 1024 ) {
                $.HN.message.alert("卫生局地址超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#hospAddress").val(hospAddress);
    		
    		var area3 = $.trim($("#area3").val());
    		if (area3 == null || area3 == "") {
    			$.HN.message.alert("请选择地区！", "消息", "warn");
    			return false;
    		}
    		
    		var staffNum = $.trim($("#staffNum").val());
    		if (staffNum == null || staffNum == "") {
    			$.HN.message.alert("请输入员工数！", "消息", "warn");
    			return false;
    		} else if (!/^\d+$/.test(staffNum)) {
    			$.HN.message.alert("你输入的员工数不是一个正整数！", "消息", "warn");
    			return false;
    		}else if (staffNum.length > 11 ) {
                $.HN.message.alert("员工数超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#staffNum").val(staffNum);

    		var contactName = $.trim($("#contactName").val());
    		if (contactName == null || contactName == "") {
    			$.HN.message.alert("请输入联系人姓名！", "消息", "warn");
    			return false;
    		}else if (contactName.length > 20 ) {
                $.HN.message.alert("联系人姓名超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#contactName").val(contactName);

    		var contactIdnum = $.trim($("#contactIdnum").val());
    		if (contactIdnum == null || contactIdnum == "") {
    			$.HN.message.alert("请输入联系人身份证号！", "消息", "warn");
    			return false;
    		} else if (!/^\d+[a-zA-Z0-9]$/.test(contactIdnum)) {
    			$.HN.message.alert("联系人身份证号只能由字母数字下划线组成且必须以数字开头！", "消息", "warn");
    			return false;
    		}else if (contactIdnum.length > 20 ) {
                $.HN.message.alert("联系人身份证号超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#contactIdnum").val(contactIdnum);

    		var contactPos = $.trim($("#contactPos").val());
    		if (contactPos == null || contactPos == "") {
    			$.HN.message.alert("请输入联系人职务！", "消息", "warn");
    			return false;
    		}else if (contactPos.length > 20 ) {
                $.HN.message.alert("联系人职务超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#contactPos").val(contactPos);

    		var contactTelephone = $.trim($("#contactTelephone").val());
    		if (contactTelephone == null || contactTelephone == "") {
    			$.HN.message.alert("请输入联系人电话！", "消息", "warn");
    			return false;
    		} else if (!/^(\d+[-]\d+)|(\d+)$/.test(contactTelephone)) {
    			$.HN.message.alert("请输入正确的联系人电话！", "消息", "warn");
    			return false;
    		}else if (contactTelephone.length > 20 ) {
                $.HN.message.alert("联系人电话超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#contactTelephone").val(contactTelephone);

    		var contactHandphone = $.trim($("#contactHandphone").val());
    		if (contactHandphone == null || contactHandphone == "") {
    			$.HN.message.alert("请输入联系人手机号！", "消息", "warn");
    			return false;
    		} else if (!/^(\d+[-]\d+)|(\d+)$/.test(contactHandphone)) {
    			$.HN.message.alert("请输入正确的联系人手机号！", "消息", "warn");
    			return false;
    		}else if (contactHandphone.length > 20 ) {
                $.HN.message.alert("联系人手机号超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#contactHandphone").val(contactHandphone);

    		var contactEmail = $.trim($("#contactEmail").val());
    		if (contactEmail == null || contactEmail == "") {
    			$.HN.message.alert("请输入联系人邮箱！", "消息", "warn");
    			return false;
    		} else if (!/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(contactEmail)) {
    			$.HN.message.alert("电子邮箱格式不正确！", "消息", "warn");
    			return false;
    		}else if (contactEmail.length > 20 ) {
                $.HN.message.alert("联系人邮箱超过限制字数！请重新输入", "消息", "warn");
                return false;
            }
    		$("#contactEmail").val(contactEmail);

    		return true;
    	} 
    
    	$(document).ready(function() {
    		$("#hospLiceStartDate,#hospLiceEndDate,#enterLiceStartDate,#enterLiceEndDate").daterangepicker({
                timePicker: true,
                format: 'YYYY-MM-DD HH:mm:ss',
                timePickerIncrement: 1,
                timePicker12Hour: false,
                timePickerSeconds: true,
                singleDatePicker: true
            });
    		
    	});
    </script>
    
</body>
</html>
